package com.me.customerdemo.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.me.customerdemo.dao.RoleMapper;
import com.me.customerdemo.pojo.Role;
import com.me.customerdemo.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServerImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Role> selectAll() {
        return roleMapper.selectAll();
    }

    @Override
    public boolean updateById(Role role) {
        return roleMapper.updateById(role)>0? true:false;
    }

    @Override
    public boolean deleteById(int id) {
        return roleMapper.deleteById(id)>0?true:false;
    }

    @Override
    public boolean apply(Role role) {
        return roleMapper.apply(role)>0?true:false;
    }

    @Override
    public PageInfo<Role> findByKeyword(int pageNum, int pageSize, String keyword) {
        PageHelper.startPage(pageNum,pageSize);
        List<Role> roles = roleMapper.findByKeyword(keyword);
        PageInfo<Role> pageInfo = new PageInfo<>(roles);
        return pageInfo;
    }

    @Override
    public Role selectById(int id) {
        return roleMapper.selectById(id);
    }

    @Override
    public boolean updataById(Role role) {
        return roleMapper.updateById(role)>0?true:false;
    }
}
